package com.yupi.springbootinit;

public class Triangle {
    private int side1;
    private int side2;
    private int side3;

    public Triangle(int side1, int side2, int side3) {
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
    }

    public String determineTriangleType() {
        if (isValidTriangle()) {
            if (side1 == side2 && side2 == side3) {
                return "等边的";
            } else if (side1 == side2 || side2 == side3 || side1 == side3) {
                return "等腰的";
            } else {
                return "不等边的";
            }
        }

        return "无效的三角形";
    }

    private boolean isValidTriangle() {
        return side1 > 0 && side2 > 0 && side3 > 0 &&
               side1 + side2 > side3 &&
               side1 + side3 > side2 &&
               side2 + side3 > side1;
    }
}
